<#macro cols title='' path='' params='' url='' page=true>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>${title}列表</title>
  <link rel="stylesheet" href="../layui/css/layui.css" media="all">
  <script type="text/javascript" src="../js/jquery.min.js"></script>
  <script type="text/javascript" src="../layui/layui.js"></script>
  <style>
    body{margin: 10px;}
    .demo-carousel{height: 200px; line-height: 200px; text-align: center;}
  </style>
</head>
<script>

var ${path}Table;
$(function(){
	layui.use(['layer', 'form', 'table', 'util'], function () {
		var layer = layui.layer,
			form = layui.form,
			table = layui.table,
			util = layui.util;
	
			${path}Table = table.render({
			elem: '#${path}List',
			method: 'post',
			cellMinWidth: 80,
			size: 'sm',
			url: '/list',
			page: 
				<#if page>
					{
						limit: 20,
						limits: [10, 20, 50, 100, 500],
						layout: ['prev', 'page', 'next', 'limit', 'count', 'refresh', 'skip']
					}
				<#else>
					false
				</#if>
			,
			request: {
				pageName: 'pageNo', // 页码的参数名称，默认：page
				limitName: 'pageSize' // 每页数据量的参数名，默认：limit
			},
			response: {
				statusCode: 'success'
			},
			parseData: function(res) {
				return {
					"code": res.status,
					"msg": res.message,
					"count": res.data.page.total,
					"data": res.data.datas
				};
			},
			cols: [[
				<#nested />
			]],
			toolbar: '#${path}Toolbar'
		});
	});
});
</script>

<body>

</#macro>
<#macro buttons path='' buttonList=[]>
<script id="${path}Toolbar">
	<#if buttonList?? && buttonList?size gt 0>
		<#list buttonList as b>
			<button class="layui-btn layui-btn-sm" lay-event="${b.href}">${b.title}</button>
		</#list>
	</#if>
	<#nested />
</script>
</#macro>
<#macro buttons2 title='' path='' pri='id' params='' buttonList=[]>
<script>
$(function(){
	layui.use(['jquery', 'form', 'table'], function () {
		var $ = layui.jquery,
			form = layui.form,
			table = layui.table;
	
		table.on('toolbar(${path})', function(obj) {
			<#if buttonList?? && buttonList?size gt 0>
				<#list buttonList as b>
					<#if b.eventType??>
						<#if b.eventType == 1>
							if(obj.event == '${b.href}') {
								event_${b.eventType}("${b.title}", "${b.width}", "${b.height}", "${b.host}${b.href}");
							}
						<#elseif b.eventType == 2>
							if(obj.event == '${b.href}') {
								event_${b.eventType}(table, "${b.title}", "${b.width}", "${b.height}", "${b.host}${b.href}?${pri}=");
							}   
						<#else>
						</#if>
					</#if>
				</#list>
			</#if>
			<#nested />
		});
	});
});
var window_width = $(window).width()-20;
var window_height = $(window).height()-20;
function event_1(title, width, height, url) {
	if(height > window_height) {
		height = window_height;
	}
	layer.open({
		type: 2, // iframe层
		title: title,
		area: [width+'px', height+'px'],
		maxmin: true,
		shade: 0.2,
		content: url+"<#if params?? && params!= ''>?${params}</#if>",
		end: function() {
			${path}Table.reload();
		}
	});
}

function event_2(table, title, width, height, url) {
	if(height > window_height) {
		height = window_height;
	}
	var data = table.checkStatus("${path}List").data;
	if(data.length == 0) {
		layer.alert("请选择一条${title}数据！");
		return false;
	} else if(data.length > 1){
		layer.alert("已选中多条数据，请选择一条${title}数据！");
		return false;
	}
	
	layer.open({
		type: 2, // iframe层
		title: title,
		area: [width+'px', height+'px'],
		maxmin: true,
		shade: 0.2,
		content: url+data[0].${pri},
		end: function() {
			${path}Table.reload();
		}
	});
}


</script>
</#macro>
<#macro content path=''>
	<table id="${path}List" lay-filter="${path}"></table>
	aaaaaaaaaaaaaaaaaa
</div>
	<#nested />
</body>
</html>
</#macro>